const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('base_unit_info', {
    unitId: {
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: "单位ID",
      field: 'unit_id'
    },
    id: {
      type: DataTypes.BIGINT,
      allowNull: false,
      comment: "项目ID",
      references: {
        model: 't_project_info',
        key: 'project_id'
      }
    },
    unitType: {
      type: DataTypes.STRING(2),
      allowNull: true,
      comment: "单位类型(1建设单位2施工单位3监理单位4专业分包单位5劳务分包单位)",
      field: 'unit_type'
    },
    unitName: {
      type: DataTypes.STRING(1000),
      allowNull: true,
      comment: "单位名称",
      field: 'unit_name'
    },
    creditCode: {
      type: DataTypes.STRING(1000),
      allowNull: true,
      comment: "统一社会信用代码",
      field: 'credit_code'
    },
    unitPeople: {
      type: DataTypes.STRING(32),
      allowNull: true,
      comment: "联系人",
      field: 'unit_people'
    },
    unitPhone: {
      type: DataTypes.STRING(1000),
      allowNull: true,
      comment: "联系方式",
      field: 'unit_phone'
    },
    remarks: {
      type: DataTypes.STRING(255),
      allowNull: true,
      comment: "备注"
    },
    isDeleted: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "是否删除",
      field: 'is_deleted'
    },
    createdUser: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "创建人",
      field: 'created_user'
    },
    createdTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "创建时间",
      field: 'created_time'
    },
    updatedUser: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "更新人",
      field: 'updated_user'
    },
    updatedTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "更新时间",
      field: 'updated_time'
    }
  }, {
    sequelize,
    tableName: 'base_unit_info',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "unit_id" },
        ]
      },
      {
        name: "index_unit_type",
        using: "BTREE",
        fields: [
          { name: "unit_type" },
        ]
      },
      {
        name: "unit_type_index",
        using: "BTREE",
        fields: [
          { name: "unit_type" },
        ]
      },
      {
        name: "i_unit_info_project_id",
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
};
